package com.ds.config;

import com.ds.controller.TestFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

/**
 * @program: springmvc
 * @description:
 * @author: Dawson.Zhang
 * @create: 2020-04-07
 **/
@Configuration
public class AdapterConfig extends WebMvcConfigurationSupport {
    @Bean
    TestFilter loginInterceptor() {
        return new TestFilter();
    }


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration addInterceptor = registry.addInterceptor(loginInterceptor());

        // 排除配置
        addInterceptor.excludePathPatterns("/error");
        addInterceptor.excludePathPatterns("/hello");
        addInterceptor.excludePathPatterns("/addUser");
        addInterceptor.excludePathPatterns("/login**");

        // 拦截配置
        addInterceptor.addPathPatterns("/**");
    }
}
